package com.usian.article.controller;

import com.usian.apis.article.AuthorControllerApi;
import com.usian.article.service.impl.AuthorServiceImpl;
import com.usian.model.article.pojos.ApAuthor;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/api/v1/author")
@RestController
public class AuthorController implements AuthorControllerApi {
    @Autowired
    private AuthorServiceImpl authorService;

    @Override
    @PostMapping("/findByUserId{id}")
    public ApAuthor findByUserId(@PathVariable Integer id) {
        ApAuthor author = authorService.getById(id);
        return author;
    }

    @Override
    @PostMapping("/save")
    public ResponseResult save(@RequestBody ApAuthor apAuthor) {
        authorService.save(apAuthor);
        return ResponseResult.okResult(apAuthor);
    }
}
